*****************************************************************************************************
***Replication Files: Electoral Rules, Women's Representation and the Qualification of Politicians***
*****************************************************************************************************

**************
***Analyses***
**************

use "~/Downloads/1994_2011_elected.dta", clear 
cd "~/Downloads"

preserve
collapse (mean) female dyn_subnat_car dyn_age dyn_party_ideol edu_level reg_magn, by(year nat_subnat)
gen post_reform = year>= 2005
replace post_reform = 0 if post_reform == .

label var post_reform "post"
label var nat_subnat "treated"

*TABLE 4 - MAIN ANALYSES
reg female 1.post_reform##1.nat_subnat, r
* outreg2 using Table4, tex replace keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, NO, Controls, NO) title("Electoral Reform and Female Representation: Share of Women Elected and Female Election Probability") nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year, r
* outreg2 using Table4, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, NO) nocons dec(3) pdec(3)
restore 

preserve
collapse (mean) female dyn_subnat_car dyn_age dyn_party_ideol edu_level reg_magn , by(year nat_subnat macro_regions)
gen post_reform = year>= 2005
replace post_reform = 0 if post_reform == .

label var post_reform "post"
label var nat_subnat "treated"

reg female 1.post_reform##1.nat_subnat year i.macro_region reg_magn, r
* outreg2 using Table4, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, YES) nocons dec(3) pdec(3)
restore 

preserve
label var post_reform "post"
label var nat_subnat "treated"

reg female 1.post_reform##1.nat_subnat, vce(cluster ID)   
* outreg2 using Table4, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, NO, Controls, NO) nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year, vce(cluster ID)
* outreg2 using Table4, tex  append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, NO) nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year i.macro_region reg_magn, vce(cluster ID)
* outreg2 using Table4, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, YES) nocons dec(3) pdec(3)

reg female i.post_reform##i.nat_subnat year i.macro_region reg_magn, vce(cluster ID) 
margins nat_subnat#post_reform  //marginal effects
margins nat_subnat, dydx(post_reform)
margins post_reform, dydx(nat_subnat)
restore


*TABLE 5 - PARTY ANALYSIS

preserve
reg female 1.post_reform##1.nat_subnat year i.macro_regions reg_magn if dyn_party_ideol ==1, vce(cluster ID) 
* outreg2 using Table5, tex replace ctitle("Left") title("Party Analysis") keep(1.post_reform 1.nat_sub 1.post_reform##1.nat_subnat) nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year i.macro_regions reg_magn if dyn_party_ideol ==2, vce(cluster ID) 
* outreg2 using Table5, tex append ctitle("CL") keep(1.post_reform 1.nat_sub 1.post_reform##1.nat_subnat) nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year i.macro_regions reg_magn if dyn_party_ideol ==3, vce(cluster ID) 
* outreg2 using Table5, tex append ctitle("Centre")  keep(1.post_reform 1.nat_sub 1.post_reform##1.nat_subnat) nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year i.macro_regions reg_magn if dyn_party_ideol ==4, vce(cluster ID) 
* outreg2 using Table5, tex append ctitle("CR") keep(1.post_reform 1.nat_sub 1.post_reform##1.nat_subnat) nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year i.macro_regions reg_magn if dyn_party_ideol ==5, vce(cluster ID) 
* outreg2 using Table5, tex append ctitle("Right") keep(1.post_reform 1.nat_sub 1.post_reform##1.nat_subnat) nocons dec(3) pdec(3)
restore 


*TABLE 6 - QUALIFICATION OF POLITICIANS

preserve
keep if lv_new == 4
drop if edu_lev == . 

ttest edu_level, by(post_reform) 
ttest edu_level if male == 1, by(post_r)
ttest edu_level if male == 0, by(post_r)

ttest dyn_subnat_car, by(post_reform) 
ttest dyn_subnat_car if male == 1, by(post_r) 
ttest dyn_subnat_car if male == 0, by(post_r) 

ttest parachute_new, by(post_reform) 
ttest parachute_new if male == 1, by(post_r) 
ttest parachute_new if male == 0, by(post_r) 

ttest edu_level, by(male) 
ttest edu_level if post==0, by(male) 
ttest edu_level if post==1, by(male)


*TABLE 7 - QUALIFICATION OF POLITICIANS, HIGH AND LOW EDUCATION 

count if male == 1 & post_re == 0 
count if male == 0 & post_re == 0 
count if male == 1 & post_re == 1 
count if male == 0 & post_re == 1 

//PRE-REFORM PANEL A, WOMEN
count if hi_edu == 1 & male == 0 & post_re == 0 //76%
count if hi_edu == 0 & male == 0 & post_re == 0 //24%
count if hi_edu == 1 & male == 0 & post_re == 1 //73%
count if hi_edu == 0 & male == 0 & post_re == 1 //27%

//POST-REFORM PANEL B, MEN
count if hi_edu == 1 & male == 1 & post_re == 0 //74% 
count if hi_edu == 0 & male == 1 & post_re == 0 //26%
count if hi_edu == 1 & male == 1 & post_re == 1 //72%
count if hi_edu == 0 & male == 1 & post_re == 1 //28%
restore 

//HOW MANY MOVE FROM SUBNATIONAL LEVELS TO NATIONAL LEVEL:
preserve
bysort ID (year): egen max_lv = max(lv_new)
duplicates drop ID , force
count if max_lv == 4
restore

use "~/Downloads/2013_candidate_elected.dta", clear  

duplicates drop lastname firstname year_birth district, force
drop if edu_level == . 

count if eletto == 1 
count if eletto == 0 

count if eletto == 1 & male == 1 //71% OF TOTAL ELECTED
count if eletto == 1 & male == 0 //29%
count if eletto == 0 & male == 1 //771 = 69% OF TOTAL NON-ELECTED
count if eletto == 0 & male == 0 //342 = 31%

//PANEL C, WOMEN 2013 ONLY
count if eletto == 0 & male == 0 & hi_edu == 1 //76% OF NON-ELECTED FEMALES
count if eletto == 0 & male == 0 & lo_edu == 1 //24%
count if eletto == 1 & male == 0 & hi_edu == 1 //69% OF ELECTED FEMALES 
count if eletto == 1 & male == 0 & lo_edu == 1 //31%

//PANEL D, MEN 2013 ONLY
count if eletto == 0 & male == 1 & hi_edu == 1 //65% OF NON-ELECTED MALES 
count if eletto == 0 & male == 1 & lo_edu == 1 //35%
count if eletto == 1 & male == 1 & hi_edu == 1 //69% OF ELECTED MALES 
count if eletto == 1 & male == 1 & lo_edu == 1 //31%


